#!/usr/bin/env python
#
# Copyright (C) 2009 Dody Suria Wijaya.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Data model classes for parsing and generating XML for the Ajax Feed API."""


__author__ = 'dodysw@gmail.com (Dody Suria Wijaya)'


import atom.core

class StatusDetailsMixIn:
    """Added method to set additional response data from Ajax Feed API
    """
    def SetResponseStatusDetail(self, responseStatus, responseDetails):
        self.responseStatus = responseStatus
        self.responseDetails = responseDetails
        return self

class Error(object, StatusDetailsMixIn):
    pass

# class to simulate xmlelement's text attribute
class MockXmlElement(object):
    def __init__(self, text):
        self.text = text

    def __str__(self):
        return self.text

class LookupFeed(object, StatusDetailsMixIn):
    def __init__(self, query='', url=''):
        self.query = MockXmlElement(query)
        self.url = MockXmlElement(url)

class FindFeedEntry(object):
    def __init__(self, title='', url='', link='', contentSnippet=''):
        self.title = MockXmlElement(title)
        self.url = MockXmlElement(url)
        self.link = MockXmlElement(link)
        self.contentSnippet = MockXmlElement(contentSnippet)

class FindFeed(object, StatusDetailsMixIn):
    def __init__(self, query='', entries=[]):
        self.query = MockXmlElement(query)
        self.entries = entries

class FeedEntry(object):
    def __init__(self, author='', categories='', content='', title='', link='',
                contentSnippet='', publishedDate=''):
        self.title = MockXmlElement(title)
        self.link = MockXmlElement(link)
        self.author = MockXmlElement(author)
        self.categories = MockXmlElement(categories)
        self.content = MockXmlElement(content)
        self.publishedDate = MockXmlElement(publishedDate)
        self.contentSnippet = MockXmlElement(contentSnippet)


class Feed(object, StatusDetailsMixIn):
    def __init__(self, author='', description='', entries=[], link='', title='',
        type=''):
        self.title = MockXmlElement(title)
        self.author = MockXmlElement(author)
        self.description = MockXmlElement(description)
        self.link = MockXmlElement(link)
        self.entries = entries
